
var express = require('express');
var router = express.Router();
const {
    questionsModel
} = require("../models/questionsModel");
const {
    knowledgePointsModel
} = require("../models/knowledgePointsModel");


// 全部知识点
router.get('/getAllKnow', async function (req, res, next) {

    let getAllKnow = await knowledgePointsModel.find({});
    res.send({
        getAllKnow
    });
});
// 添加题目
router.post('/addQuestions', async function (req, res, next) {
    let {question,analysis,answer,KnowledgePointId,RightKey,score}=req.body;
    let result = await questionsModel.create({question,analysis,answer:JSON.parse(answer) ,KnowledgePointId,RightKey,score});
    if (result) {
        res.send({
            message: '添加成功',
            code: 1
        });
    } else {
        res.send({
            message: '添加失败',
            code: 0
        });
    }



});

module.exports = router;